﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace OAuthClient
{
    public partial class _Default : System.Web.UI.Page
    {
        public string Provider
        {
            get
            {
                if (Request.PathInfo.StartsWith("/authenticated/"))
                {
                    //string[] parts = Request.PathInfo.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
                    //if (parts.Length >= 2)
                    //    return parts[1];
                    //else
                    //    return "Unknown Provider";
                    string email = Request.QueryString["email"];
                    if (string.IsNullOrEmpty(email))
                        return "Unknown Provider";
                    else
                        return email;
                }
                else
                    return String.Empty;
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Request.PathInfo.StartsWith("/authenticated/"))
                    ShowAuthenticateMessage();
                DataBind();
            }
        }

        private void ShowAuthenticateMessage()
        {
            AuthenticatedPanel.Visible = true;
        }
    }
}
